﻿@{
    ViewBag.Title = "Lập kế hoạch định hướng năm";
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
    List<SelectListItem> lstNam = new List<SelectListItem>();
    lstNam.Add(new SelectListItem
    {
        Value = "-1",
        Text = "-- Chọn năm --"
    });
    lstNam.Add(new SelectListItem
    {
        Value = "2012",
        Text = "2012"
    });
    lstNam.Add(new SelectListItem
    {
        Value = "2013",
        Text = "2013"
    });
    lstNam.Add(new SelectListItem
    {
        Value = "2014",
        Text = "2014"
    });
    lstNam.Add(new SelectListItem
    {
        Value = "2015",
        Text = "2015"
    });
    lstNam.Add(new SelectListItem
    {
        Value = "2016",
        Text = "2016"
    });
    lstNam.Add(new SelectListItem
    {
        Value = "2017",
        Text = "2017"
    });


    List<SelectListItem> lstDaotao = new List<SelectListItem>();
    lstDaotao.Add(new SelectListItem
    {
        Value = "-1",
        Text = "-- Chọn nhóm chỉ tiêu --"
    });
    lstDaotao.Add(new SelectListItem
    {
        Value = "0",
        Text = "Đào tạo"
    });
    lstDaotao.Add(new SelectListItem
    {
        Value = "1",
        Text = "Nghiên cứu khoa học"
    });
    lstDaotao.Add(new SelectListItem
    {
        Value = "2",
        Text = "Tuyển sinh"
    });
    lstDaotao.Add(new SelectListItem
    {
        Value = "3",
        Text = "Hội nhập quốc tế"
    });
    lstDaotao.Add(new SelectListItem
    {
        Value = "4",
        Text = "Tổ chức các bộ"
    });
    lstDaotao.Add(new SelectListItem
    {
        Value = "5",
        Text = "Thanh tra pháp chế"
    });
    DHQGHN.PM2.Models.DHQG.NguoiDungModel nguoiDungInfo = (DHQGHN.PM2.Models.DHQG.NguoiDungModel)Session["NguoiDungInfo"];

}
<link href="~/Content/standard_form_nhaplieu.css" rel="stylesheet" />
<link href="@Url.Content("~/Content/jquery-ui.1.10.2.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery.maskedinput.js")"></script>
<script>
    function datePicker() {
        var option = {
            //dayNamesMin: ["CN", "Thứ 2", "Thứ 3", "Thứ 4", "Thứ 5", "Thứ 6", "Thứ 7"],
            dayNamesMin: ["CN", "2", "T3", "T4", "T5", "T6", "T7"],
            monthNames: ["Tháng 1", "Tháng 2", "Tháng 3", "Tháng 4", "Tháng 5",
                "Tháng 6", "Tháng 7", "Tháng 8", "Tháng 9", "Tháng 10", "Tháng 11", "Tháng 12"],
            dateFormat: "dd/mm/yy",
            onSelect: function (selectedDate) {
                //alert(selectedDate);

            }
        };

        $("#Hanbaocao").mask("99/99/9999", { placeholder: "dd/mm/yyyy" });
        $("#Hanbaocao").datepicker(option);
    }
    function isNumeric(n) {
        return !isNaN(parseFloat(n)) && isFinite(n);
    }
    $(document).ready(function () {
        datePicker();
        $('.restartall').blur(function () {
            if ($(this).val() != "") {
                if (!isNumeric($(this).val())) {
                    alert('Bạn vui lòng nhập kiểu số !');
                    $(this).val('');
                }
            }
        });
        $(".restartall").each(function () {
            var b = $(this).attr('name');
            calculateSum(b);
            $(this).keyup(function () {
                var a = $(this).attr('name');
                calculateSum(a);
            });
        });
        //$("#nhm").live("change", function () {
        //    if ($('input[name="inlineRadioOptions"]:checked').val() == 'dv') {
        //        $("#btnBCDonVi").show();
        //    } else if ($('input[name="inlineRadioOptions"]:checked').val() == 'n') {
        //        $("#btnBCDonVi").hide();
        //    }
        //});

        //$("#dvn").live("change", function () {
        //    if ($('input[name="inlineRadioOptions"]:checked').val() == 'dv') {
        //        $("#btnBCDonVi").show();
        //    } else if ($('input[name="inlineRadioOptions"]:checked').val() == 'n') {
        //        $("#btnBCDonVi").hide();
        //    }
        //});
    })
    function calculateSum(a) {
        var sum = 0;
        //iterate through each textboxes and add the values
        $(".restartall").each(function () {
            if ($(this).attr('name') == a) {
                //add only if the value is number
                if (!isNaN(this.value) && this.value.length != 0) {
                    sum += parseFloat(this.value);
                }
            }

        });
        //.toFixed() method will roundoff the final sum to 2 decimal places
        $('.' + a + '').val(sum);
    }
</script>
<style>
    tbdata {
        table-layout: fixed;
        word-wrap: break-word;
        font-size: small;
    }

    #parent {
        max-height: 500px;
    }

    .ct1 {
        text-align: center;
    }

    .e-input3 {
        background-color: #F7CECE;
        border: 1px solid #ddd;
        text-align: left;
        border-radius: 3px;
        padding: 5px;
        height: 26px;
        font-family: "Open Sans", arial !important;
        box-shadow: 0 1px 1px rgba(50,50,50,0.1);
    }

    .e-input1 {
        background-color: #ddd;
        border: 1px solid #ddd;
        text-align: left;
        border-radius: 3px;
        padding: 5px;
        height: 26px;
        font-family: "Open Sans", arial !important;
        box-shadow: 0 1px 1px rgba(50,50,50,0.1);
    }

    .e-input2 {
        border: 1px solid #ddd;
        background: #bee6ff;
        text-align: left;
        border-radius: 3px;
        padding: 5px;
        height: 26px;
        font-family: "Open Sans", arial !important;
        box-shadow: 0 1px 1px rgba(50,50,50,0.1);
    }

    .restartall {
        width: 113%;
        margin-left: -6%;
    }
</style>
<div class="page-bar">
    <ul class="page-breadcrumb" style="padding: 4px;">
        <li>
            <i class="fa fa-home"></i>
            <a href="#">@ViewBag.CurrentMenuName</a>
        </li>
    </ul>
</div>
<div class="row margin-bottom-20">
    <div class="col-md-5">
        <div class="row" style="margin-top:5px;">
            @Html.Label("Năm kế hoạch", new { @class = "col-md-5", id = "lb1" })
            <div class="col-md-7">
                @Html.DropDownList("Namlapbc", lstNam, new { id = "Namlapbc", style = "margin:0px;", @class = "form-control input-sm" })
            </div>
        </div>

    </div>
    <div class="col-md-5">
        <div class="row" style="margin-top:5px;">
            @Html.Label("Mốc kiểm soát", new { @class = "col-md-5", id = "lb1" })
            <div class="col-md-7">
                <select id="mocks" class="form-control input-sm">
                    <option value="-1">[--Chọn mốc kiểm soát--]</option>
                </select>
            </div>
        </div>
    </div>
    <div class="col-md-2">
        <div class="row" style="margin-top:5px; text-align:right;">
            <div class="col-md-12">
                <button type="button" class="btn btn-sm btn-default" id="Create" style="width: 90px; margin-bottom: 5px; cursor:pointer;"><i class="fa fa-plus-square-o"></i> Xem</button>
            </div>
        </div>
    </div>
</div>

<div class="row">
    <label id="thongbao" style="margin-left: 1.5%;color: red;"></label>
</div>

<div id="gridContent" align="center">
    <table class="table table-striped table-bordered table-hover dataTable no-footer" style="width:100%;">
        <thead>
            <tr class="header">
                <th scope="col">
                    STT
                </th>
                <th scope="col" style="width:12%;">
                    Năm kế hoạch
                </th>
                <th scope="col" class="hidden-480" style="width:40%;">
                    Tên kế hoạch
                </th>
                <th scope="col" class="hidden-480" style="width:18%;">
                    Ngày cập nhật kế hoạch
                </th>
                <th scope="col" class="hidden-480" style="width:22%;">
                    Mốc trạng thái
                </th>
                <th scope="col" width="8%;">Thao tác</th>
            </tr>
        </thead>
        <tbody id="body"></tbody>
    </table>
</div>


<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" data-backdrop="static" aria-hidden="true">
    <div class="modal-dialog modal-lg" style="width:90%;">
        <div class="modal-content">
            <div class="modal-header" style="color: white; background-color: #23C34C; border-color: #23C34C; ">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title" id="myModalLabel">Theo dõi thực hiện kế hoạch</h4>
            </div>
            <div class="modal-body">
                <div>
                    <div class="row">
                        <div class="col-md-8">
                            <form role="form">
                                <div class="col-md-6">
                                    <label class="radio-inline">
                                        <input type="radio" name="inlineRadioOptions" id="dvn" value="dv"> Chọn đơn vị:
                                        <select disabled="disabled" class="form-control" id="donvi"></select>
                                    </label>
                                </div>
                                <div class="col-md-6">
                                    <label class="radio-inline chn">
                                        <input type="radio" name="inlineRadioOptions" id="nhm" value="nhom" checked="checked"> Chọn nhóm: <select class="form-control" id="nhomdonvi"></select>
                                    </label>
                                </div>
                            </form>
                        </div>
                        <div class="col-md-4">
                            <div class="col-md-8">
                                <label>
                                    Chọn nhóm chỉ tiêu
                                </label>
                                <select class="form-control" id="nhomchitieu"></select>
                            </div>
                        </div>
                    </div>
                    <br />
                    <br />
                    <div style="" id="parent">
                        <table class="table table-bordered table-hover" id="tbdata" style="table-layout: fixed; word-wrap: break-word; font-size: small;">
                            <thead id="hhh">

                            </thead>
                            <tbody id="bdy"></tbody>
                        </table>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                @*<button type="button" data-dismiss="modal" class="btn btn-primary">Export</button>*@
                @*<button type="button" onclick="onOpenPdfData()" class="btn btn-primary" id="Print">Print</button>
                    <button type="button" onclick="onExportData()" class="btn btn-primary">Export</button>*@

                @*<button type="button" onclick="onExportKhungChiTieu()" class="btn btn-primary">Khung CT</button>*@
                @*<button type="button" onclick="onExportDHQG()" class="btn btn-primary">Export ĐHQG</button>*@
                @*<button type="button" onclick="onExportDonVi()" class="btn btn-primary">Export ĐV</button>*@

                

                @*<div id="btnBCDonVi" class="btn-group">
                    <a href="#" data-toggle="dropdown" class="btn btn-primary">
                        Báo cáo thực hiện đơn vị
                    </a>
                    <ul class="dropdown-menu bottom-up no-angle pull-right right">
                        <li>
                            <a onclick="onExportBaoCaoTHDV()" data-index="4" style="cursor:pointer;"> <i class="fa fa-file-excel-o"></i> Kết Xuất Excel</a>
                        </li>
                        <li>
                            <a onclick="onPrintBaoCaoTHDV()" data-index="4" style="cursor:pointer;"> <i class="fa fa-print"></i> In báo cáo</a>
                        </li>
                    </ul>
                </div>*@
                @if (nguoiDungInfo.listDonVi[0].MaDonVi == "KHTC")
                {
                    <div id="btnBCDonVi2" class="btn-group">
                        <a href="#" data-toggle="dropdown" class="btn btn-primary" @*style="margin:0px; padding:0px;"*@>
                            Báo cáo thực hiện đơn vị
                        </a>
                        <ul class="dropdown-menu bottom-up no-angle pull-right right">
                            <li>
                                <a onclick="onExportBaoCaoTHDV()" data-index="4" style="cursor:pointer;"> <i class="fa fa-file-excel-o"></i> Kết Xuất Excel</a>
                            </li>
                            <li>
                                <a onclick="onPrintBaoCaoTHDV()" data-index="4" style="cursor:pointer;"> <i class="fa fa-print"></i> In báo cáo</a>
                            </li>
                        </ul>
                    </div>
                    <div class="btn-group">
                        <a href="#" data-toggle="dropdown" class="btn btn-primary" @*style="margin:0px; padding:0px;"*@>
                            Báo cáo thực hiện toàn ĐHQG
                        </a>
                        <ul class="dropdown-menu bottom-up no-angle pull-right right">
                            <li>
                                <a onclick="onExportDHQG()" data-index="4" style="cursor:pointer;"> <i class="fa fa-file-excel-o"></i> Kết Xuất Excel</a>
                            </li>
                            <li>
                                <a onclick="onPrintDHQG()" data-index="4" style="cursor:pointer;"> <i class="fa fa-print"></i> In báo cáo</a>
                            </li>
                        </ul>
                    </div>
                }
                else if (nguoiDungInfo.listDonVi[0].CoQuyenGiamSat == true)
                {
                    <div class="btn-group">
                        <a href="#" data-toggle="dropdown" class="btn btn-primary" @*style="margin:0px; padding:0px;"*@>
                            Báo cáo thực hiện toàn ĐHQG
                        </a>
                        <ul class="dropdown-menu bottom-up no-angle pull-right right">
                            <li>
                                <a onclick="onExportDHQG()" data-index="4" style="cursor:pointer;"> <i class="fa fa-file-excel-o"></i> Kết Xuất Excel</a>
                            </li>
                            <li>
                                <a onclick="onPrintDHQG()" data-index="4" style="cursor:pointer;"> <i class="fa fa-print"></i> In báo cáo</a>
                            </li>
                        </ul>
                    </div>
                }
                else
                {
                    <div id="btnBCDonVi2" class="btn-group">
                        <a href="#" data-toggle="dropdown" class="btn btn-primary">
                            Báo cáo thực hiện đơn vị
                        </a>
                        <ul class="dropdown-menu bottom-up no-angle pull-right right">
                            <li>
                                <a onclick="onExportBaoCaoTHDV()" data-index="4" style="cursor:pointer;"> <i class="fa fa-file-excel-o"></i> Kết Xuất Excel</a>
                            </li>
                            <li>
                                <a onclick="onPrintBaoCaoTHDV()" data-index="4" style="cursor:pointer;"> <i class="fa fa-print"></i> In báo cáo</a>
                            </li>
                        </ul>
                    </div>
                    @*<div class="btn-group">
                    <a href="#" data-toggle="dropdown" class="btn btn-primary">
                        Báo cáo thực hiện toàn ĐHQG
                    </a>
                    <ul class="dropdown-menu bottom-up no-angle pull-right right">
                        <li>
                            <a onclick="onExportDHQG()" data-index="4" style="cursor:pointer;"> <i class="fa fa-file-excel-o"></i> Kết Xuất Excel</a>
                        </li>
                        <li>
                            <a onclick="onPrintDHQG()" data-index="4" style="cursor:pointer;"> <i class="fa fa-print"></i> In báo cáo</a>
                        </li>
                    </ul>
                </div>*@   
                }


                @*<div class="btn-group">
                        <a href="#" data-toggle="dropdown" class="btn btn-primary" >
                            Export
                        </a>
                        <ul class="dropdown-menu bottom-up no-angle pull-right right">
                            <li>
                                <a onclick="onExportData()" data-index="4" style="cursor:pointer;"> <i class="fa fa-pencil"></i> Kết Xuất Excel</a>
                            </li>
                            <li>
                                <a onclick="onOpenPdfData()" data-index="4" style="cursor:pointer;"> <i class="fa fa-trash-o"></i> In báo cáo</a>
                            </li>
                        </ul>
                    </div>*@


                @*<div class="btn-group">
                        <a href="#" data-toggle="dropdown" class="btn btn-primary" >
                            Báo cáo thực hiện
                        </a>
                        <ul class="dropdown-menu bottom-up no-angle pull-right right">
                            <li>
                                <a onclick="onExportBCTHMultiSheet()" data-index="4" style="cursor:pointer;"> <i class="fa fa-pencil"></i> Kết Xuất Excel</a>
                            </li>
                            <li>
                                <a onclick="onPrintBCTHMultiSheet()" data-index="4" style="cursor:pointer;"> <i class="fa fa-trash-o"></i> In báo cáo</a>
                            </li>
                        </ul>
                    </div>*@
                @*<div class="btn-group">
                        <a href="#" data-toggle="dropdown" class="btn btn-primary">
                            Báo cáo TH - ĐV
                        </a>
                        <ul class="dropdown-menu bottom-up no-angle pull-right right">
                            <li>
                                <a onclick="onExportChiTieuRieng()" data-index="4" style="cursor:pointer;"> <i class="fa fa-pencil"></i> Kết Xuất Excel</a>
                            </li>
                            <li>
                                <a onclick="onPrintChiTieuRieng()" data-index="4" style="cursor:pointer;"> <i class="fa fa-trash-o"></i> In báo cáo</a>
                            </li>
                        </ul>
                    </div>*@
                @*<button type="button" onclick="onExportChiTieuRieng()" class="btn btn-primary">Export CTR</button>*@
                @*<div class="btn-group">
                        <a href="#" data-toggle="dropdown" class="btn btn-primary">

                            Khung CT
                        </a>
                        <ul class="dropdown-menu bottom-up no-angle pull-right right">
                            <li>
                                <a onclick="onExportKhungChiTieu()" data-index="4" style="cursor:pointer;"> <i class="fa fa-pencil"></i> Kết Xuất Excel</a>
                            </li>
                            <li>
                                <a onclick="onPrintKhungChiTieu()" data-index="4" style="cursor:pointer;"> <i class="fa fa-trash-o"></i> In báo cáo</a>
                            </li>
                        </ul>
                    </div>*@

                <button type="button" class="btn btn-default" data-dismiss="modal">Đóng</button>

            </div>
        </div>
    </div>
</div>
<script>
    @functions{
           public string GetAntiForgeryToken()
           {
               string cookieToken, formToken;
               AntiForgery.GetTokens(null, out cookieToken, out formToken);
               return cookieToken + "," + formToken;
           }
       }
</script>
<script src="@Url.Content("~/Scripts/DHQG/Theodoi.js?v=1")" type="text/javascript"></script>
<script>
    $(function () {
        var initData = {
            VerificationToken: "@GetAntiForgeryToken()",
            GetallChitieu: "@Url.Action("GetallChitieu","Kehoachnam")",
            GetallNamkehoach: "@Url.Action("GetallNamkehoach", "Kehoachnam")",
            GetallChitieubynamchitieu: "@ViewBag.URL",
            GetallChitieubynamchitieubydonvi: "@Url.Action("GetallChitieubynamchitieubydonvi", "Kehoachnam")",
            GetDonViByNhom: "@Url.Action("GetDonViByNhom", "Kehoachnam")",
            GetKehoachbyNamkehoach: "@Url.Action("GetKehoachbyNamkehoach", "Kehoachnam")",
            Getallnhomdonvi: "@Url.Action("Getallnhomdonvinew", "Kehoachnam")",
            Getallstatus: "@Url.Action("Getallstatus", "Kehoachnam")",
            GetAllDonViByNhomID: "@Url.Action("GetAllDonViByNhomIDnew", "Kehoachnam")",
            Getallchitieubymacap2: "@Url.Action("Getallchitieubymacap2", "Kehoachnam")",
            GetNamkehoachbyID: "@Url.Action("GetNamkehoachbyID", "Kehoachnam")",
            GetAllDvCtbyNKH: "@Url.Action("GetAllDvCtbyNKH", "Kehoachnam")",
            SaveDonViChiTieu: "@Url.Action("SaveDonViChiTieu", "Kehoachnam")",
            DonviID: '@ViewBag.DonviID',
            MaDV: '@ViewBag.MADV',
            QUYENGIAMSAT: '@ViewBag.QUYENGIAMSAT',
            UpdateStatusid: '@Url.Action("UpdateStatusid", "Kehoachnam")',
            CheckNamChot: '@Url.Action("CheckNamChot", "Kehoachnam")',
            GetDonviChuaPhanHoi: '@Url.Action("GetDonviChuaPhanHoi", "Kehoachnam")',
            GetDonViID: '@Url.Action("GetDonViID", "Kehoachnam")',
            GetallKHTH: '@Url.Action("GetallKHTH", "Kehoachnam")',
            GetSumKH: '@Url.Action("GetSumKH", "Kehoachnam")',
            GetSumKHTH: '@Url.Action("GetSumKHTH", "Kehoachnam")',
            CheckChitieubymacap1: "@Url.Action("CheckChitieubymacap1", "Kehoachnam")",
            GetKhRiengbyDV: "@Url.Action("GetKhRiengbyDV", "Kehoachnam")",
            Getkehoachthrieng: "@Url.Action("Getkehoachthrieng", "Kehoachnam")",
            Getmockiemsoatbynam: "@Url.Action("Getmockiemsoatbynam", "Kehoachnam")",
            Getmockiemsoatactivebynam: "@Url.Action("Getmockiemsoatactivebynam", "Kehoachnam")",
            GetallKHTHNEW: "@Url.Action("GetallKHTHNEW", "Kehoachnam")",
            GetKehoachByNamKeHoach_NhomDV_NhomCT: "@Url.Action("GetKehoachByNamKeHoach_NhomDV_NhomCT", "Kehoachnam")"
        };
        Theodoi.init(initData);

    });

    function onExportData() {
        var namKeHoachID = $("#Namlapbc").val();
        var donViId = 0;
        var nhomDonViId = 0;
        //alert($('input[name=inlineRadioOptions]:checked').val());
        if ($('input[name="inlineRadioOptions"]:checked').val() == 'dv') {
            donViId = $('#donvi').val();
        }
        else nhomDonViId = $('#nhomdonvi').val();
        var maKH = $('#Namlapbc option:selected').text();
        //alert('namKHId=' + namKeHoachID +
        //   'nhomDonViId=' + nhomDonViId +
        //   'chiTieuId=' + maChiTieu +
        //   'donViId=' + donViId);
        window.location.href = '/BaoCao/ExportData' + '?namKHId=' + namKeHoachID +
           '&nhomDonViId=' + nhomDonViId +
           '&namKH=' + maKH +
           '&donViId=' + donViId;
    }

    function onExportKhungChiTieu() {
        var namKeHoachID = $("#Namlapbc").val();

        window.location.href = '/BaoCao/ExportKhungChiTieu' + '?namKHId=' + namKeHoachID;
    }

    function onPrintKhungChiTieu() {
        var namKeHoachID = $("#Namlapbc").val();

        window.open('/BaoCao/PrintKhungChiTieu' + '?namKHId=' + namKeHoachID);
    }

    function onExportDHQG() {
        var namKeHoachID = $("#Namlapbc").val();
        var maKH = $('#Namlapbc option:selected').text();
        var moks = $('#mocks').val();
        window.location.href = '/BaoCao/ExportDataDHQG' + '?namKHId=' + namKeHoachID + '&namKH=' + maKH + '&mocKS=' + moks;
    }

    function onPrintDHQG() {
        var namKeHoachID = $("#Namlapbc").val();
        var maKH = $('#Namlapbc option:selected').text();
        var moks = $('#mocks').val();
        window.open('/BaoCao/PrintDataDHQG' + '?namKHId=' + namKeHoachID + '&namKH=' + maKH + '&mocKS=' + moks);
    }

    function onExportDonVi() {
        var namKeHoachID = $("#Namlapbc").val();
        var maKH = $('#Namlapbc option:selected').text();
        var donViId = 0;
        //alert($('input[name=inlineRadioOptions]:checked').val());
        if ($('input[name="inlineRadioOptions"]:checked').val() == 'dv') {
            donViId = $('#donvi').val();
        }

        window.location.href = '/BaoCao/ExportDataDonVi' +
            '?namKHId=' + namKeHoachID +
            '&donViId=' + donViId +
            '&namKH=' + maKH;
    }

    function onExportChiTieuRieng() {
        var namKeHoachID = $("#Namlapbc").val();
        var maKH = $('#Namlapbc option:selected').text();
        var donViId = 0;
        //alert($('input[name=inlineRadioOptions]:checked').val());
        if ($('input[name="inlineRadioOptions"]:checked').val() == 'dv') {
            donViId = $('#donvi').val();
        }

        window.location.href = '/BaoCao/ExportChiTieuRieng' +
            '?namKHId=' + namKeHoachID +
            '&donViId=' + donViId +
            '&namKH=' + maKH;
    }

    function onPrintChiTieuRieng() {
        //PrintChiTieuRieng
        var namKeHoachID = $("#Namlapbc").val();
        var maKH = $('#Namlapbc option:selected').text();
        var donViId = 0;
        //alert($('input[name=inlineRadioOptions]:checked').val());
        if ($('input[name="inlineRadioOptions"]:checked').val() == 'dv') {
            donViId = $('#donvi').val();
        }

        window.open('/BaoCao/PrintChiTieuRieng' +
            '?namKHId=' + namKeHoachID +
            '&donViId=' + donViId +
            '&namKH=' + maKH);
    }

    function onExportBCTHMultiSheet() {
        var namKeHoachID = $("#Namlapbc").val();
        var donViId = 0;
        var nhomDonViId = 0;
        if ($('input[name="inlineRadioOptions"]:checked').val() == 'dv') {
            donViId = $('#donvi').val();
        }
        else nhomDonViId = $('#nhomdonvi').val();
        var maKH = $('#Namlapbc option:selected').text();
        //alert('namKHId=' + namKeHoachID +
        //   'nhomDonViId=' + nhomDonViId +
        //   'chiTieuId=' + maChiTieu +
        //   'donViId=' + donViId);
        window.location.href = '/BaoCao/ExportBCTHMultiSheet' + '?namKHId=' + namKeHoachID +
           '&nhomDonViId=' + nhomDonViId +
           '&donViId=' + donViId +
            '&namKH=' + maKH;

        //ExportMultiSheet(int namKHId, int nhomDonViId, int donViId, string namKH)
    }

    function onPrintBCTHMultiSheet() {

        var namKeHoachID = $("#Namlapbc").val();
        var donViId = 0;
        var nhomDonViId = 0;
        if ($('input[name="inlineRadioOptions"]:checked').val() == 'dv') {
            donViId = $('#donvi').val();
        }
        else nhomDonViId = $('#nhomdonvi').val();
        var maKH = $('#Namlapbc option:selected').text();
        //alert('namKHId=' + namKeHoachID +
        //   'nhomDonViId=' + nhomDonViId +
        //   'chiTieuId=' + maChiTieu +
        //   'donViId=' + donViId);
        window.open('/BaoCao/PrintBCTHMultiSheet' + '?namKHId=' + namKeHoachID +
           '&nhomDonViId=' + nhomDonViId +
           '&donViId=' + donViId +
            '&namKH=' + maKH);
    }

    function onOpenPdfData() {
        var namKeHoachID = $("#Namlapbc").val();
        var donViId = 0;
        var nhomDonViId = 0;
        //alert($('input[name=inlineRadioOptions]:checked').val());

        if ($('input[name="inlineRadioOptions"]:checked').val() == 'dv') {
            donViId = $('#donvi').val();
        }
        else nhomDonViId = $('#nhomdonvi').val();

        var maKH = $('#Namlapbc option:selected').text();

        //window.location.href = '/Kehoachnam/OpenPdfData' + '?namKHId=' + namKeHoachID +
        //   '&nhomDonViId=' + nhomDonViId +
        //   '&maChiTieuCap1=' + maChiTieu +
        //   '&donViId=' + donViId;
        var win = window.open('/BaoCao/OpenPdfData' + '?namKHId=' + namKeHoachID +
           '&nhomDonViId=' + nhomDonViId +
           '&namKH=' + maKH +
           '&donViId=' + donViId, '_blank');
        win.focus();

    }

    function onExportBaoCaoTHDV() {
        //ExportKHTHDonVi(int namKHId, string namKH, int donViId)
        var namKeHoachID = $("#Namlapbc").val();
        var maKH = $('#Namlapbc option:selected').text();
        var donViId = 0;
        var miks = $('#mocks').val();
        if ($('input[name="inlineRadioOptions"]:checked').val() == 'dv') {
            donViId = $('#donvi').val();
            nhomDonViId = -1;
            window.location.href = '/BaoCao/ExportKHTHDonVi' +
            '?namKHId=' + namKeHoachID +
            '&namKH=' + maKH +
            '&nhomDonViId=' + nhomDonViId +
            '&mocKS=' + miks +
            '&donViId=' + donViId;
        }
        else
        {
            //alert("Bạn chưa chọn đơn vị báo cáo!");
            nhomDonViId = $('#nhomdonvi').val();
            donViId = -1;
            window.location.href = '/BaoCao/ExportKHTHDonVi' +
            '?namKHId=' + namKeHoachID +
            '&namKH=' + maKH +
            '&nhomDonViId=' + nhomDonViId +
            '&mocKS=' + miks +
            '&donViId=' + donViId;
        } 
    }

    function onPrintBaoCaoTHDV() {
        //PrintDataDonVi(int namKHId, string namKH, int donViId)
        var namKeHoachID = $("#Namlapbc").val();
        var maKH = $('#Namlapbc option:selected').text();
        var donViId = 0;
        var miks = $('#mocks').val();
        if ($('input[name="inlineRadioOptions"]:checked').val() == 'dv') {
            donViId = $('#donvi').val();
            nhomDonViId = -1;
            window.open('/BaoCao/PrintDataDonVi' +
            '?namKHId=' + namKeHoachID +
            '&namKH=' + maKH +
            '&nhomDonViId=' + nhomDonViId +
            '&mocKS=' + miks +
            '&donViId=' + donViId);
        }
        else {
            //alert("Bạn chưa chọn đơn vị báo cáo!");
            nhomDonViId = $('#nhomdonvi').val();
            donViId = -1;
            window.location.href = '/BaoCao/PrintDataDonVi' +
            '?namKHId=' + namKeHoachID +
            '&namKH=' + maKH +
            '&nhomDonViId=' + nhomDonViId +
            '&mocKS=' + miks +
            '&donViId=' + donViId;
        }  
    }

    //Huydq: fix độ cao của gridview để luôn hiện thị thanh cuộn
    function fixLayoutGridview() {
        var h = document.body.clientHeight;
        var w = document.body.clientWidth;
        var totalHeaderFooterHeight = 250;
        var totalMaginTopBottom = 60;
        var gridviewDialog = $('.modal-dialog');
        $(gridviewDialog).height(h - totalMaginTopBottom);
        $('#parent').height(h - totalHeaderFooterHeight - totalMaginTopBottom);
    }
    $(document).ready(function () {
        fixLayoutGridview();
    })

    function onExportBaoCaoTHDC() {
        var namKeHoachID = $("#Namlapbc").val();
        window.location.href = '/BaoCao/ExportTongHopDC' + '?namKhId=' + namKeHoachID;
    }

</script>

